1. Field of the Invention
This invention relates generally to pointers and, more specifically, to a stack pointer which selects between the next available location in the stack memory and a pre-decremented location in the stack memory and which performs either a post increment operation or post decrement operation after execution of a current instruction and a method therefor.
2. Description of the Prior Art
A "call" instruction and a "return" instruction are two instructions that work together to allow subroutines to be execute in a processor system. The "call" instruction and the "return" instruction work together to allow the called subroutine to automatically return back to the instruction that called it. This allows for the multiple nesting of subroutines.
During read and write operations to the top of the stack memory, the top of the stack will appear as a set of ordinary Random Access Memory (RAM) locations. In an instruction cycle that has four phases, it is necessary to read the top of the stack memory during the second phase of the instruction cycle and to write to the top of the stack memory during the fourth phase. It is desirable for reads and writes to the top of the stack to operate on the last value written, rather than on a blank location in the stack memory. This requires that the stack pointer be decremented at the very beginning of the second phase so that the last location in the stack memory where data was written may be read.
This creates a timing conflict. A "call" instruction requires that the stack pointer be pointing to the next available location in the stack memory during the second phase of a write operation. However, the stack pointer also needs to be pointing to the directly preceding location during the second phase for a read during a top of stack operation.
Therefore, a need existed to provide an improved stack pointer. The improved stack pointer must be able to pre-decode a decremented value, and to have this value selectable by a multiplexer in order to read this location. The improved stack pointer must further be able to pre-decode a decremented value and to have post increment/decrement options.